<extend name="./public/frame.html"/>
<block name="content">
<form class="layui-form layui-form-pane1" action="" method="post">
	<input type="hidden" name="ad_id" value="{$data.ad_id}">
	
	<div class="layui-form-item">
		<label class="layui-form-label">乘客端倒计时广告图片</label>
		<div class="layui-input-block">
			<button type="button" class="layui-btn" id="test1">
			  <i class="layui-icon">&#xe67c;</i>上传图片
			</button>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">城内司机端倒计时广告图片</label>
		<div class="layui-input-block">
			<button type="button" class="layui-btn" id="test1">
			  <i class="layui-icon">&#xe67c;</i>上传图片
			</button>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">城际司机端倒计时广告图片</label>
		<div class="layui-input-block">
			<button type="button" class="layui-btn" id="test1">
			  <i class="layui-icon">&#xe67c;</i>上传图片
			</button>
		</div>
	</div>
	<div class="layui-form-item" id="img_url">
		<label class="layui-form-label"> </label>
		<div class="layui-input-block">
			<img src="{$data.img_url}" alt="" style="width: 300px;height: 400px">
			<input type="hidden" name="img_url" value="{$data.img_url}">
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" type="button" id="submits">立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
<script>
layui.use(['form','laydate','upload'], function(){
	var form = layui.form;
	var laydate = layui.laydate;
	var upload = layui.upload;
  //执行实例
  var uploadInst = upload.render({
    elem: '#test1' //绑定元素
    ,url: '{:url("upload")}' //上传接口
    ,done: function(res){
    	if(res.status == 0){
    		$("#img_url").find('img').attr('src',res.data);
    		$("#img_url").find('input').val(res.data);
    		$("#img_url").show();
    		form.render();
    	}
    	console.log(res)
    }
    ,error: function(res1){
    	console.log(res1);
      //请求异常回调
    }
  });
	
	//墨绿主题
	laydate.render({
	elem: '#test6-1' //指定元素
	,type: 'date'
	,theme: 'molv'
	//,range: true
	,trigger: 'click'
	});
	
	laydate.render({
	elem: '#test6-2' //指定元素
	,type: 'date'
	,theme: 'molv'
	//,range: true
	,trigger: 'click'
	});
 


	//事件监听
	form.on('select', function(data){
		console.log(this);
	})
	
	form.on('select(aihao)', function(data){
		console.log(data);
	});
	
	form.on('checkbox', function(data){
		var type = $(this).data('type');
		if(type == 'all'){
			var child = $('.fa').find('.item_child');
			child.each(function(index, item){
					item.checked = data.elem.checked;
			});
			form.render('checkbox');

		}
	 // console.log(this.checked, data.elem.checked);
	});
	
	//监听提交
 $(document).on('click', '#submits', function(){

		$('form').submit();
	}) 

});

</script>
</block>
